<?php

namespace app\admin\model\mental;

use think\Model;


class TestMain extends Model
{

    

    

    // 表名
    protected $name = 'mental_testmain';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'pay_mode_text'
    ];
    

    
    public function getTypeList()
    {
        return ['skip' => __('Type skip'), 'mark' => __('Type mark'), 'component' => __('Type component'), 'sorts' => __('排序')];
    }

    public function getPayModeList()
    {
//        return ['0' => __('Pay_mode 0'), '1' => __('Pay_mode 1'), '2' => __('Pay_mode 2')];
        return ['0' => __('Pay_mode 0'), '1' => __('Pay_mode 1')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getPayModeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_mode']) ? $data['pay_mode'] : '');
        $list = $this->getPayModeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function Category(){
        return $this->hasOne('Category','id','category_id')->bind('name');
    }



}
